﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RoundAttribute.cs" company="JDML Consulting Ltd.">
//   Copyright 2011 Photon Project - http://photon.codeplex.com
// </copyright>
// <summary>
//   Defines the RoundAttribute type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Photon.ComponentModel
{
    using System;
    using Modelling;

    public class RoundAttribute : PropertyChangingAttribute
    {
        public override bool OnChanging(object instance, MetaModelProperty property, object oldValue, ref object newValue)
        {
            newValue = Math.Round((double)newValue, Digits);
            return true;
        }

        public int Digits { get; set; }
    }
}
